home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10632 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  107 lines

  1. Path: news.telepac.pt!usenet
  2. From: vortex@telepac.pt (VORTEX)
  3. Newsgroups: comp.lang.c++
  4. Subject: CRC READING ERROR  HELP PLEASE!!!!
  5. Date: Sat, 09 Mar 1996 05:38:45 GMT
  6. Organization: telepac
  7. Message-ID: <4hqk16$2e8@vivaldi.telepac.pt>
  8. Reply-To: vortex@telepac.pt
  9. NNTP-Posting-Host: por1_p7.telepac.pt
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12.  
  13. Can anyone help inserting a routine in this program that make a hook
  14. to int24h and return the fail code everytime...
  15. The intension is if it occurs a CRC error i put my own message on
  16. screen instead of DOS msg.
  17.  
  18. Thanks in advance
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. //
  32. //This reading 8 files named SOURCE.1 to SOURCE.8
  33. //& join them together in a final D:\FINAL.EXE
  34. //
  35.  
  36.  
  37. #include <stdio.h>
  38. #include <fcntl.h>
  39. #include <sys\stat.h>
  40. #include <io.h>
  41. #include <stdlib.h>
  42. #include <dos.h>
  43. #include <string.h>
  44.  
  45. #define READ_BYTES (62L * 1024L)
  46.  
  47. void main(void)
  48. {
  49.     char buf[READ_BYTES+1];
  50.     char file_on_disk[16]="source.";
  51.     char filename[129]="d:\\final.exe";
  52.     int f_src, f_dst;
  53.     unsigned int bytes;
  54.     int i, num_disks=8;
  55.     char s1[20],s2[4];
  56.  
  57.  
  58. // Check if destination file exists. If so TRUNCAT to 0 bytes
  59. //                                     If no CREAT a new one with 0 bytes
  60.  
  61.      if((f_dst= creat(filename, S_IWRITE  )) == -1) {
  62.        printf("Cannot open destination file : %s\n",filename);
  63.        exit(1);
  64.      }
  65.  
  66.      close(f_dst);
  67.  
  68.     _dos_creat(filename, O_APPEND, &f_dst);
  69.  
  70.  
  71.    for (i=0;i<num_disks;i++) {
  72.  
  73.     strcpy(s1,file_on_disk);
  74.      itoa(i+1,s2,10);                 // Converts an Integer to a String
  75.       strcat(s1,s2);
  76.  
  77.     if((f_src = open(s1, O_RDONLY | O_BINARY)) == -1) {
  78.      printf("Cannot open source file: %s\n", s1);
  79.       exit(1);
  80.     }
  81.  
  82.  
  83.     printf("Reading : %s\n",s1);
  84.  
  85.  
  86.  
  87. // This is where all the work is done (read from source file
  88. // and write to destination, until done)
  89.  
  90.     while (_dos_read(f_src, buf, READ_BYTES, &bytes)==0) {
  91.       write(f_dst, buf, bytes);
  92.         if (bytes < READ_BYTES) break;
  93.     }
  94.  
  95.      _dos_close(f_src);
  96.  
  97.    }
  98.  
  99. // Close destination file
  100.  
  101.     close(f_dst);
  102.  
  103. }
  104.  
  105.  
  106.  
  107.